package dao;

import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;

@Entity
@NamedQueries({
	@NamedQuery(name="searchCustomerCode",query=" from Customer c where c.OID = :code"),
	@NamedQuery(name="searchCustomerName",query=" from Customer c where c.nmCustomer like :name"),
	@NamedQuery(name="searchCustomerFone",query=" from Customer c where c.OID <> :code and c.nrDDDFone = :ddd and c.nrFone = :fone")
})
public class Customer {
	@Id
	@GeneratedValue
	private int OID;
	private String nmCustomer;
	private String nrFone;
	private String nrDDDFone;
	private Date dtBirth;
	private String idSex;
	private String idCivilStatus;
	private String deEmail;
		
	@ManyToOne(cascade = {CascadeType.PERSIST,CascadeType.MERGE,CascadeType.REFRESH})
	private City city;
	private String deDistrict;
	private String nrZipCode;
	private String deAddress;
	private String nrAddress;
	private String deComplement;
	
	private String nrFone2;
	private String nrDDDFone2;
	private String nrCellular;
	private String nrDDDCellular;

	public String getFone(){
		return "(" + this.nrDDDFone + ") " + this.nrFone;
	}
	public String getFone2(){
		return this.nrDDDFone2 + this.nrFone2;
	}
	public String getCellular(){
		return this.nrDDDCellular + this.nrCellular;
	}
	
	public int getOID() {
		return OID;
	}
	public void setOID(int oID) {
		OID = oID;
	}	
	public String getNmCustomer() {
		return nmCustomer;
	}
	public void setNmCustomer(String nmCustomer) {
		this.nmCustomer = nmCustomer;
	}
	public String getNrFone() {
		return nrFone;
	}
	public void setNrFone(String nrFone) {
		this.nrFone = nrFone;
	}
	public String getNrDDDFone() {
		return nrDDDFone;
	}
	public void setNrDDDFone(String nrDDDFone) {
		this.nrDDDFone = nrDDDFone;
	}
	public Date getDtBirth() {
		return dtBirth;
	}
	public void setDtBirth(Date dtBirth) {
		this.dtBirth = dtBirth;
	}
	public String getIdSex() {
		return idSex;
	}
	public void setIdSex(String idSex) {
		this.idSex = idSex;
	}
	public String getIdCivilStatus() {
		return idCivilStatus;
	}
	public void setIdCivilStatus(String idCivilStatus) {
		this.idCivilStatus = idCivilStatus;
	}
	public String getDeEmail() {
		return deEmail;
	}
	public void setDeEmail(String deEmail) {
		this.deEmail = deEmail;
	}
	public City getCity() {
		return city;
	}
	public void setCity(City city) {
		this.city = city;
	}
	public String getDeDistrict() {
		return deDistrict;
	}
	public void setDeDistrict(String deDistrict) {
		this.deDistrict = deDistrict;
	}
	public String getNrZipCode() {
		return nrZipCode;
	}
	public void setNrZipCode(String nrZipCode) {
		this.nrZipCode = nrZipCode;
	}
	public String getDeAddress() {
		return deAddress;
	}
	public void setDeAddress(String deAddress) {
		this.deAddress = deAddress;
	}
	public String getNrAddress() {
		return nrAddress;
	}
	public void setNrAddress(String nrAddress) {
		this.nrAddress = nrAddress;
	}
	public String getDeComplement() {
		return deComplement;
	}
	public void setDeComplement(String deComplement) {
		this.deComplement = deComplement;
	}
	public String getNrFone2() {
		return nrFone2;
	}
	public void setNrFone2(String nrFone2) {
		this.nrFone2 = nrFone2;
	}
	public String getNrDDDFone2() {
		return nrDDDFone2;
	}
	public void setNrDDDFone2(String nrDDDFone2) {
		this.nrDDDFone2 = nrDDDFone2;
	}
	public String getNrCellular() {
		return nrCellular;
	}
	public void setNrCellular(String nrCellular) {
		this.nrCellular = nrCellular;
	}
	public String getNrDDDCellular() {
		return nrDDDCellular;
	}
	public void setNrDDDCellular(String nrDDDCellular) {
		this.nrDDDCellular = nrDDDCellular;
	}
	public String toString(){
		return this.nmCustomer;
	}
}
